#pragma once

#include "core/base_scene.h"
#include "entity/character.h"

class GameLogic final : public cocos2d::Node
{
public:
    static GameLogic* getInstance();

public:
    void startGame();

    virtual void update(float delta);
    virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event); 
    virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *unused_event); 
    virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event); 
    virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *unused_event);

private:
    GameLogic();
    ~GameLogic();
    bool init();

    void changeScene(int sceneId);
    void createPlayer();

private:
    static GameLogic *_instance;
    BaseScene *_scene;
    Character *_player;
    cocos2d::EventListenerTouchOneByOne *_interactiveListener;
};